<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>消息模板管理列表</title>
    <link href="../../layui/css/layui.css" rel="stylesheet">
    <link href="../../static/css/style.css" rel="stylesheet">
    <script src="../../static/js/jquery.min.js"></script>
    <script src="../../static/js/jquery.cookie.js"></script>
    <script src="../../layui/layui.js"></script>
    <script src="../../static/js/base.js"></script>
    <script src="../../static/js/ax.js"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
    <script src="../../static/js/html5.js"></script>
    <script src="../../static/js/respond.js"></script>
    <![endif]-->
</head>
<body>

<div class="layui-fluid">
    <div class="layui-card content-wrap">
        <!--查询-->
        <!--<div class="layui-form layui-card-header layuiadmin-card-header-auto">-->
        <form class="layui-form layui-form-pane">
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-sm3">
                        <label class="layui-form-label">模板编码</label>
                        <div class="layui-input-block">
                            <input type="text" id="mtCode" placeholder="请输入模板编码" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-col-sm3">
                        <label class="layui-form-label">模板标题</label>
                        <div class="layui-input-block">
                            <input type="text"  id="mtTitle" placeholder="请输入模板标题" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-col-sm3">
                        <a id="doSearch" class="layui-btn add_btn" data-type="reload"><i class="layui-icon layui-icon-search"></i>搜索</a>
                        <button type="reset" class="layui-btn delete_btn"><i class="layui-icon layui-icon-delete"></i>清空</button>

                    </div>
                </div>
            </div>
        </form>


        <!--数据列表展示-->
        <div>
            <!--<script type="text/html" id="optToolbar">-->
                <!--<div>-->
                    <!--<button class="layui-btn layuiadmin-btn-useradmin add_btn ax-btn" lay-event="Seebtn">查看</button>-->
                <!--</div>-->
            <!--</script>-->

            <table class="layui-hide" id="dataListTable"
                   lay-filter="active"></table>
        </div>


    </div>
</div>


</body>

<script>

    var table;
    var tableObj;

    layui.use(['table','form','layer'], function() {
        table = layui.table;
        var form = layui.form,
            layer=layui.layer;


        tableObj = ax.VTable({
            id: 'loadDataList',
            elem : '#dataListTable',
            autoPrefix: false,
            url :schoolWebUrl + '/api/message/template/list',
            // toolbar: '#optToolbar',
            title:'消息模板列表',
            cols : [ [
                // {type : 'checkbox', fixed : 'left'},
                {type: 'numbers', width : 80, title : '序号', fixed : 'left'},
                {field : 'mtCode', title : '模板编码', width : 200, fixed : 'left' },
                {field : 'mtTitle', minWidth : 250, title : '模板标题'},
                {field : 'pushType', minWidth : 250, title : '推送方式' },
                {field : 'createUser', width : 150, title : '创建人' },
                {field : 'createTime', width : 180, title : '创建时间' }
            ] ],
            done: function (res, curr, count) {
                $('.layui-table-body').find("table" ).find("tbody").children("tr").on('dblclick',function(){
                    var rowIndex = JSON.stringify($('.layui-table-body').find("table" ).find("tbody").find(".layui-table-hover").data('index'));
                    top.layer.open({
                        type: 2,
                        title:'模板详情',
                        area: ['90%', '80%'],
                        fixed: true, //不固定
                        maxmin: true,
                        content: './school/message/messageTemplateDetail.html?id=' + res.data[rowIndex].id
                    });
                });
            }

        });

        var $ = layui.$;

        $('#doSearch').on('click', function(){
            searchData();
        });

        //头工具栏事件
        // table.on('toolbar()', function(obj){
        //     var checkStatus = table.checkStatus(obj.config.id);
        //     switch(obj.event){
        //         case 'Seebtn':
        //             var data = checkStatus.data;
        //             if(data.length<=0) {
        //                 top.layer.open({
        //                     title: '信息提示'
        //                     ,content: '请选择查看的数据！'
        //                 });
        //                 break;
        //             }
        //             top.layer.open({
        //                 type: 2,
        //                 title:'查看信息',
        //                 area: ['90%', '80%'],
        //                 fixed: true, //不固定
        //                 maxmin: true,
        //                 content: './school/message/messageTemplateDetail.html?id=' + data[0].id
        //             });
        //             break;
        //     };
        // });

    });

    function searchData() {
        //执行重载
        tableObj.reload({
            page : {
                curr: 1 //重新从第 1 页开始
            },
            where : {
                mtCode : $('#mtCode').val(),
                mtTitle : $('#mtTitle').val()
            }
        });
    }
</script>
</html>